<?php
    class StatisticController extends CpController
    { 
        public function init(){
            $url = new Url();
            $this->breadcrumbs[] = array('name'=>'Thống kê handset','link'=>$url->createUrl("statistic/index"),'class'=>'');
        }
        public function actionIndex(){

            $error = "";
            $from_date = isset($_GET["from_date"]) ? trim($_GET["from_date"]) : date("d-m-Y");
            $to_date = isset($_GET["to_date"]) ? trim($_GET["to_date"]) : date("d-m-Y");
            $username = isset($_GET["username"]) ? trim($_GET["username"]) : "";

            $data = array();
            $login=true;
            if($username !=""){
                $login=Login::getUserLogin($username);
                if($login!=false){
                    $userid=$login['id']; 
                }
                else{
                    $userid=null;
                } 
            }else{
                $userid=null;
            }

            $data = AAppView::getDataSearch($login,$from_date, $to_date, $userid);
            $this->render(
            "index"
            , array(
            "from_date"=>$from_date
            , "to_date"=>$to_date
            , "error"=>$error
            , "data"=>$data
            , "username"=>$username
            )
            );

        }        
    }
?>
